﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>操作</title>
    <script src="../../Scripts/easyUI145/jquery.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
    <script src="../../Comm/Gener.js" type="text/javascript"></script>
    <link href="../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <script type="text/javascript">

        var fk_node = GetQueryString("FK_Node");
        var fk_flow = GetQueryString("FK_Flow");
        var workid = GetQueryString("WorkID");
        var fid = GetQueryString("FID");
        $(function () {

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");

            handler.AddUrlData();
            var data = handler.DoMethodReturnString("OP_GetStatus");
            data = JSON.parse(data);

            var html = "";

            //打包下载.
            if (data.CanPackUp == 1) 
                html += PackUp(data.PrintType);

           //是否可以删除流程.
           if (data.IsCanDelete==1) 
               html += DeleteFlow();
 
            //增加回滚.
            if (data.CanRollBack == "1")
                html += Rollback();

            //增加撤销.
            if (data.CanUnSend == "1")
                html += addUnSend();

            //增加催办.
            if (data.CanFlowPress == "1")
                html += addHurry();

            //增加流程结束.
            if (data.CanFlowOver == "1")
                html += addFlowOver();

            //调整工天
            if (data.CanChangCHRole != undefined)
                html += addCHNode(data.CanChangCHRole);


            $("#ccop").append(html);

        });

        function RollbackIt() {
            window.location.href = "../Rollback.htm?WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow");
        }

        //回滚流程
        function Rollback() {

            var html = addBlockBegin("回滚流程");

            html += "回滚流程:<a href=\"javascript:RollbackIt();\" >执行回滚</a>。";
            html += "<br />说明：从指定的节点上从新审批.";

            html += addBlockEnd();

            return html;
        }

        //删除流程
        function DeleteFlow(isCan) {

            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("删除流程");

            if (isCan == "true") {
                html += "功能执行:<a href=\"javascript:DeleteFlowInstance('" + GetQueryString("fk_flow") + "','" + GetQueryString("WorkID") + "')\" >点击执行删除流程</a>。";
                html += "<br />说明：如果执行流程将会被彻底的删除。";
            }
            else {
                html += "您没有删除该流程的权限。";
            }

            html += addBlockEnd();
            return html;
        }

        //取回审批
        function TackBack(isCan, fromNode, toNode) {

            if (typeof isCan == "undefined") {
                return "";
            }

            var html = addBlockBegin("取回审批");

            if (isCan) {
                html += "功能执行:<a href=\"javascript:Takeback('" + workid + "','" + fk_flow + "','" + fromNode + "','" + toNode + "')\" >点击执行取回审批流程</a>。";
                html += "<br />说明：如果被成功取回，ccflow就会把停留在别人工作节点上的工作发送到您的待办列表里。";
            }
            else {
                html += "您没有此权限。";
            }

            html += addBlockEnd();
            return html;
        }

        //催办
        function addHurry() {

            var html = addBlockBegin("工作催办");
             html += "功能执行:<a href =\"javascript:Press('" + fk_flow + "','" + workid + "','" + fid + "')\" >工作催办</a>。";
            html += addBlockEnd();
            return html;
        }
         //催办.
        function Press(fk_flow, workid, fid) {

            var msg = window.prompt('请输入催办信息', '该工作因为xxx原因，需要您优先处理.');
            if (msg == null)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("WorkID", workid);
            handler.AddPara("FID", fid);
            handler.AddPara("Msg", msg);
            var data = handler.DoMethodReturnString("Runing_Press");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            alert(data);
            return;
        }

        //流程结束
        function addFlowOver() {

            var html = addBlockBegin("流程结束");
            html += "功能执行:<a href =\"javascript:FlowOver('" + fk_flow + "','" + workid + "','" + fid + "')\" >流程结束</a>。";
            html += addBlockEnd();
            return html;
        }

        function FlowOver(fk_flow,workid,fid) {
            if (confirm('您确定要结束流程操作吗 ?') == false)
                return;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_MyFlow");
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("WorkID", workid);
            var data = handler.DoMethodReturnString("MyFlow_StopFlow");
            alert(data);
        }
        //撤销发送
        function addUnSend() {

            var html = addBlockBegin("撤销发送");
            html += "功能执行:<a href =\"javascript:UnSend('" + fk_flow + "','" + workid + "','" + fid + "')\" >撤销发送</a>。";
            html += addBlockEnd();
            return html;
        }

        //恢复使用流程.
        function addRollBack() {

            var html = addBlockBegin("恢复启用流程数据到结束节点");
            html += "功能执行:<a href=\"javascript:DoFunc('OP_ComeBack','" + workid + "','" + fk_flow + "','" + fk_node + "')\" >点击执行恢复流程</a>。";
            html += "<br />说明：如果被成功恢复，ccflow就会把待办工作发送给最后一个结束流程的工作人员。";
            html += addBlockEnd();

            return html;
        }


        //撤销挂起
        function addUnHungUp() {

            var html = addBlockBegin("取消挂起");

            html += "功能执行:<a href=\"javascript:DoFunc('OP_UnHungUp','" + workid + "','" + fk_flow + "','" + fk_node + "')\" >点击执行取消挂起流程</a>。";
            html += "<br />说明：解除流程挂起的状态。";

            html += addBlockEnd();

            return html;
        }

        ///增加打印.
        function PackUp(printType) {

            var fk_node = GetQueryString("FK_Node");
            if (fk_node == null)
                fk_node = GetQueryString("NodeID");

            //如果printType是undefined或者null 就执行打包下载
            if (printType == null || printType == undefined || printType==0) {
                var html = addBlockBegin("打印/打包下载");
                html += "功能执行:<a href='../Packup.htm?FileType=zip,pdf&WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow") + "&NodeID=" + GetQueryString("FK_Node") + "&FK_Node=" + GetQueryString("FK_Node") + "' >执行打印</a>。";
                html += "<br />说明：把表单输出到html,pdf,zip文件里，执行下载或打印.";
            } else {
                var html = addBlockBegin("RTF/Word下载");
                html += "功能执行:<a href='javaScript:void(0)' onclick='WinOpen(\"../PrintDoc.htm?WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow") + "&NodeID=" + GetQueryString("FK_Node") + "&FK_Node=" + GetQueryString("FK_Node") + "\")' >执行打印</a>。";
                html += "<br />说明：把表单输出到Word文件里，执行下载或打印.";
            }

            html += addBlockEnd();
            return html;
        }


        //删除流程.
        function DeleteFlowInstance(flowNo, workid) {
            var url = '../DeleteFlowInstance.htm?FK_Flow=' + flowNo + '&WorkID=' + workid;
            WinOpen(url);
        }

        function DoFunc(doType, workid, fk_flow, fk_node) {

            if (doType == 'OP_DelFlow' || doType == 'Reset') {
                if (confirm('您确定要执行吗？') == false)
                    return;
            }

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddPara("WorkID", workid);
            handler.AddPara("FK_Flow", fk_flow);
            handler.AddPara("FK_Node", fk_node);
            var data = handler.DoMethodReturnString(doType);
            $("#opmsg").empty().append(data);
        }

        function Takeback(workid, fk_flow, fk_node, toNode) {
            if (confirm('您确定要执行吗？') == false)
                return;
            var url = '../../GetTask.aspx?DoType=Tackback&FK_Flow=' + fk_flow + '&FK_Node=' + fk_node + '&ToNode=' + toNode + '&WorkID=' + workid;
            window.location.href = url;
        }

        function UnSend(fk_flow, workID, fid) {
            if (confirm('您确定要执行撤销吗?') == false)
                return;

            var url = Handler + "?DoType=OP_UnSend&FK_Node=<%=FK_Node %>&FK_Flow=" + fk_flow + "&WorkID=" + workID;

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_WorkOpt_OneWork");
            handler.AddUrlData();
            var data = handler.DoMethodReturnString("OP_UnSend");
            $("#opmsg").empty().append(data);
        }

        function addBlockBegin(title) {
            var html = "<table class='Table' cellspacing='0' cellpadding='0' border='0' style='width:100%;margin-bottom:5px;'>";
            html += "<tr><td class='GroupTitle'>" + title + "</td></tr>";
            html += "<tr><td style='padding:10px'>";
            return html;
        }

        function addBlockEnd() {
            return "</td></tr></table>";
        }

        function addCHNode(data) {
            var html = addBlockBegin("调整工天");
            var IsReadOnly = 1;
            if (data == 1)
                IsReadOnly = 0;

           html += "功能执行:<a href='../CH.htm?WorkID=" + GetQueryString("WorkID") + "&FK_Flow=" + GetQueryString("FK_Flow") +"&FK_Node=" + GetQueryString("FK_Node") + "&IsReadOnly="+IsReadOnly+"' >调整工天</a>。";
           html += "<br />说明：调整工天，计算工时。";

            return html;
        }
    </script>
    <div id="ccop" style="width: 100%; height: auto">
    </div>
    <div id="opmsg" style="width: 100%; height: auto">
    </div>
</body>
</html>
